package com.bh.ledger.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bh.common.utils.DateUtils;
import com.bh.ledger.domain.JcCostApportionment;
import com.bh.ledger.mapper.JcCostApportionmentMapper;
import com.bh.ledger.service.IJcCostApportionmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 分段单据成本分摊Service业务层处理
 *
 * @author slx
 * @date 2023-04-24
 */
@Service
public class JcCostApportionmentServiceImpl extends ServiceImpl<JcCostApportionmentMapper, JcCostApportionment> implements IJcCostApportionmentService {
    @Autowired
    private JcCostApportionmentMapper jcCostApportionmentMapper;

    /**
     * 查询分段单据成本分摊
     *
     * @param id 分段单据成本分摊主键
     * @return 分段单据成本分摊
     */
    @Override
    public JcCostApportionment selectJcCostApportionmentById(Long id) {
        return jcCostApportionmentMapper.selectById(id);
    }

    /**
     * 查询分段单据成本分摊列表
     *
     * @param jcCostApportionment 分段单据成本分摊
     * @return 分段单据成本分摊
     */
    @Override
    public List<JcCostApportionment> selectJcCostApportionmentList(JcCostApportionment jcCostApportionment) {
        return jcCostApportionmentMapper.selectJcCostApportionmentList(jcCostApportionment);
    }

    /**
     * 新增分段单据成本分摊
     *
     * @param jcCostApportionment 分段单据成本分摊
     * @return 结果
     */
    @Override
    public int insertJcCostApportionment(JcCostApportionment jcCostApportionment) {
        jcCostApportionment.setCreateTime(DateUtils.getNowDate());
        return jcCostApportionmentMapper.insert(jcCostApportionment);
    }

    /**
     * 修改分段单据成本分摊
     *
     * @param jcCostApportionment 分段单据成本分摊
     * @return 结果
     */
    @Override
    public int updateJcCostApportionment(JcCostApportionment jcCostApportionment) {
        return jcCostApportionmentMapper.updateById(jcCostApportionment);
    }

    /**
     * 批量删除分段单据成本分摊
     *
     * @param ids 需要删除的分段单据成本分摊主键
     * @return 结果
     */
    @Override
    public int deleteJcCostApportionmentByIds(Long[] ids) {
        return jcCostApportionmentMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除分段单据成本分摊信息
     *
     * @param id 分段单据成本分摊主键
     * @return 结果
     */
    @Override
    public int deleteJcCostApportionmentById(Long id) {
        return jcCostApportionmentMapper.deleteById(id);
    }
}
